<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阶乘</title>
</head>
<body>
  <script>
    var n = Math.floor(Math.random()*10);
    var sum = 1;
    for (var i = n; i > 1 ; i--) {
      sum *= i;
    }
    console.log(n);
    console.log(sum);
  </script>
</body>
</html>